<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/28
 * Time: 11:17
 */
namespace App\Http\Controllers\api;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use phpDocumentor\Reflection\Types\Null_;

class RegisterController extends Controller
{
    function store(Request $request)
    {//  name   pass
        if($request->password=='undefined'||$request->name=='undefined'){
            return response('姓名为空或者密码为空');
        }
        $user = new User();
        $user->password =$request->password;
        $user->name =$request->name;
        $users = DB::table('users')->where('name',$user->name)->first();
        if($users!=Null){
            return response('2');
        }
        $user->save();
    }
    function create(Request $request)
    {   $name=new User();
        $name->userName=$request->userName;
        $name->password =$request->password;
        $users = DB::table('users')->where('name',$name->userName)->first();
        if($users==Null){
            return response('无此ID');
        }elseif ($users->password==$name->password){
            return response('1');
        }elseif($users->password!=$name->password){
            return response('密码错误');
        }
    }
    function destroy()
    {

    }
}